package com.fortune.service.impl;

import com.fortune.dao.DAccountInfoDao;
import com.fortune.dao.DStoreOutDao;
import com.fortune.dto.in.dStoreOut.DStoreOutListDto;
import com.fortune.entity.DUserInfo;
import com.fortune.service.DStoreOutService;
import com.fortune.vo.dStoreOut.DStoreOutInfo;
import com.fortune.vo.dStoreOut.DStoreOutInfoDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.UUID;

@Service
public class DStoreOutServiceImpl implements DStoreOutService {
    @Autowired
    private DStoreOutDao dStoreOutDao;

    /**
     * 查询出库单列表
     * @param companyId
     * @param mStoreOutListDto
     * @return
     */
    @Override
    public List<DStoreOutInfo> queryDStoreOutList(DUserInfo dUserInfo, DStoreOutListDto dStoreOutListDto) {
        return dStoreOutDao.queryDStoreOutList(dUserInfo,dStoreOutListDto);
    }

    /**
     * 查询出库单列表个数
     * @param companyId
     * @param mStoreOutListDto
     * @return
     */
    @Override
    public int queryDStoreOutListCount(DUserInfo dUserInfo, DStoreOutListDto dStoreOutListDto) {
        return dStoreOutDao.queryDStoreOutListCount(dUserInfo,dStoreOutListDto);
    }
    /**
     * 出库单详情
     * @param companyId
     * @param id
     * @return
     */
    @Override
    public DStoreOutInfoDetail queryDStoreOutInfoDetail(DUserInfo dUserInfo,String id) {
        return dStoreOutDao.queryDStoreOutInfoDetail(dUserInfo,id);
    }
    /**
     * 确定发货
     * @param companyId
     * @param detail
     * @return
     */
    @Override
    @Transactional
    public int updateDStoreOutShipType(DUserInfo dUserInfo,String id) {
        int num = dStoreOutDao.updateType(dUserInfo,id);
        if (num < 1){
            throw new RuntimeException("确定发货失败");
        }
        return 1;
    }
}
